package com.example.vdmtest.tools;


import android.os.Environment;

import com.vivo.ic.dm.Config;
import com.vivo.ic.dm.impl.DownloadNetChangeInterface;
import com.vivo.ic.dm.impl.DownloadNotiDealer;
import com.vivo.ic.dm.impl.DownloadNotification;

public class DownloadConfig extends Config {
    private static final String PATH = Environment.getExternalStorageDirectory() + "/DMDownload";
    private int mCoreSize = 3;
    private int mMaxDownloadsAllowed = 2;
    private DownloadNotification mNotifier;
    private DownloadNotiDealer mNotiDealer;
    private DownloadNetChangeInterface mNetDealer;
    
    private DownloadConfig(final Builder builder) {
        mNotifier = builder.mNotifier;
        mNotiDealer = builder.mNotiDealer;
        mNetDealer = builder.mNetDealer;
    }
    
    @Override
    public String getDefaultDownloadPath() {
        return PATH;
    }
    
    @Override
    public int getMaxConcurrentDownloadsAllowed() {
        return mMaxDownloadsAllowed;
    }

    public void setMaxConcurrentDownloadsAllowed(int max) {
        mMaxDownloadsAllowed = max;
    }

    @Override
    public int getMultiDownloadCoreSize() {
        return mCoreSize;
    }
    
    public void setMultiDownloadCoreSize(int size) {
        mCoreSize = size;
    }
    
    @Override
    public DownloadNotification getNotification() {
        return mNotifier;
    }

    @Override
    public DownloadNotiDealer getNotiDealer() {
        return mNotiDealer;
    }

    @Override
    public DownloadNetChangeInterface getNetChangeDealer() {
        return mNetDealer;
    }



    /**
     * 构造器
     * @author wangzhenyu
     *
     */
    public static class Builder {
        private DownloadNotification mNotifier;
        private DownloadNotiDealer mNotiDealer;
        private DownloadNetChangeInterface mNetDealer;
        
        public DownloadConfig build() {
            return new DownloadConfig(this);
        }
        /**
         * 设置自定义的通知栏显示
         */
        public Builder setDownloadNotifier (DownloadNotification notifier) {
            mNotifier = notifier;
            return this;
        }
        
        /**
         * 设置自定义的通知栏处理程序
         */
        public Builder setDownloadNotiDealer (DownloadNotiDealer dealer) {
            mNotiDealer = dealer;
            return this;
        }
        
        /**
         * 设置自定义的网络切换处理
         */
        public Builder setNetChangeDealer(DownloadNetChangeInterface netDealer) {
            mNetDealer = netDealer;
            return this;
        }
    }
    
}
